<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>


<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="static/html5shiv.js"></script>
<script type="text/javascript" src="static/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/magic-input.min.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/share/widget_dcfc73f.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/share/all_62b93ee.css" />
<!--[if IE 6]>
<script type="text/javascript" src="static/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>文件列表</title>
<style type="text/css">
.clearfix,.global-clearfix{
	zoom : 1;
}
.crumbs a {
	color: #06c;
	text-decoration: none;
}
</style>
</head>
  
<body>
<div id="doc" class="doc-file-selector" style="margin-left: 10px">
	<div id="bd" class="doc-file-selector-bd">
		<div class="module-crumbs-toolbar">
			<div class="bar">
				<span class="crumbs"><span class="item">全部文件</span></span>
				<a href="javascript:;" class="view" title="该视图暂不可用"></a>
				<a href="javascript:;" class="list list-selected"></a>
				<a class="search-button" href="javascript:;" style="display: inline;"></a>
				<form action="javascript:void(0);" class="search-form">
					<span class="search-key-wrapper" style="display: none;">
						<a class="search-ico" href="javascript:;" ></a>
						<input class="search-key" type="textbox" placeholder="搜索我的私有云文件" style="margin-top: 0px;">
						<a class="search-clear" href="javascript:;" style="display: none;"></a>
						<a class="search-submit" href="javascript:;" ></a>
					</span>
				</form>
			</div>
		</div>
		<div class="NHcGw" style="display: block;">
			<div class="list-view-home">
				<div class="CMxQsC"></div>
				<div class="list" style="height: 346px;overflow:auto;"></div>
			</div>
		</div>
	</div>
	<div id="ft">
		<div class="module-file-selectorbar">
			<div class="file-selectorbar-btns global-clearfix">
				<a href="javascript:;" class="sbtn sure"><b>确定</b></a>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath}/static/layer/2.4/layer.js"></script>

<script type="text/javascript" src="${pageContext.request.contextPath}/static/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
$(function(){
	var parentId = 0;
	
	info = function(){
		$.ajax({
			type: "post",
			url : "/nebula/fileAndFolder/all-list.action",
			data : {
				parentId : parentId,
			},
			dataType: "json",
			success : function(_data){
				var html = "";
				$.each(_data.data,function(index,content){
					if(content.isFolder == 1){
						html +=
						'<div class="item" id="'+content.id+'" style="height: 45px">'
							+'<div class="fufHyA c1" style="width: 60%">'
								+'<span class="MPbHyA">'
									+'<input class="mgc mgc-primary" type="checkbox" name="check-one" id="check-one" data-id="'+content.id+'">'
								+'</span>'
								+'<span class="ico global-icon-16" style="background: url(/nebula/'+content.icon+')"></span>'
								+'<div class="name">'
									+'<span class="name-text-wrapper">'
										+'<span class="name-text enabled" title="'+content.name+'">'+content.name+'</span>'
									+'</span>'
								+'</div>'
							+'</div>'
							+'<div class="fufHyA" style="width: 16%">'+content.fileSize+'</div>'
							+'<div class="fufHyA" style="width: 23%">'+content.updatedtime+'</div>'
						+'</div>'
					}else{
						html +=
						'<div class="item" id="'+content.id+'" style="height: 45px">'
							+'<div class="fufHyA c1" style="width: 60%">'
								+'<span class="MPbHyA">'
									+'<input class="mgc mgc-primary" type="checkbox" name="check-one" id="check-one" data-id="'+content.id+'">'
								+'</span>'
								+'<span class="ico global-icon-16" style="background: url(/nebula/'+content.icon+')"></span>'
								+'<div class="name">'
									+'<span class="name-text-wrapper">'
										+'<span class="name-text" style="cursor: default;" title="'+content.name+'">'+content.name+'</span>'
									+'</span>'
								+'</div>'
							+'</div>'
							+'<div class="fufHyA" style="width: 16%">'+content.fileSize+'</div>'
							+'<div class="fufHyA" style="width: 23%">'+content.updatedtime+'</div>'
						+'</div>'
					}
				});
				$(".CMxQsC").css("padding-right","17px");
				$(".CMxQsC ").html(
					'<div class="item">'
						+'<div class="fufHyA c1" style="width: 60%">'
							+'<span class="MPbHyA chk-all">'
								+'<input class="mgc mgc-primary" type="checkbox" name="check-all" id="check-all">'
							+'</span>'
							+'<div class="name">'
								+'<span>文件名</span>'
							+'</div>'
						+'</div>'
						+'<div class="fufHyA" style="width: 16%">大小</div>'
						+'<div class="fufHyA" style="width: 23%;border-right: none;">修改日期</div>'
					+'</div>'
				);
				if(html == ""){
					$(".list-view-home .list").html(
						'<div style="text-align: center;line-height: 40px;color: #333;">没有数据<div>'
					)
				}else{
					$(".list-view-home .list").html(html);
				}
			}
		});
	};
	
	info();
	
	$(".search-key").bind("keypress",function(event){
		if(event.keyCode == "13"){
			$(".search-submit").click();
		}
	});

	$(".search-submit").click(function(){
		if($(".search-key").val().trim() != ""){
			$(".search-clear").show();
			$(".crumbs").html(
				'<a node-type="crumbs-item" data-id="0" class="item" href="javascript:;">返回上一级</a>'
				+'<span class="crumbs-sep">|</span>'
				+'<a node-type="crumbs-item" data-id="0" class="item" href="javascript:;">全部文件</a>'
				+'<span class="crumbs-sep">&gt;</span>'
				+'<span class="item">搜索：\"'+$(".search-key").val().trim()+'\"</span>'
			);
			$.ajax({
				type: "post",
				url : "/nebula/fileAndFolder/search-all-list.action",
				data: {
					queries : $(".search-key").val().trim(),
				},
				dataType: "json",
				success : function(_data){
					var html = "";
					var i = 0 , j = 0;
					$.each(_data.data,function(index,content){
						if(content.isFolder == 1){
							i += 1;
							html +=
							'<div class="item" id="'+content.id+'" style="height: 45px">'
								+'<div class="fufHyA c1" style="width: 60%">'
									+'<span class="MPbHyA">'
										+'<input class="mgc mgc-primary" type="checkbox" name="check-one" id="check-one" data-id="'+content.id+'">'
									+'</span>'
									+'<span class="ico global-icon-16" style="background: url(/nebula/'+content.icon+')"></span>'
									+'<div class="name">'
										+'<span class="name-text-wrapper">'
											+'<span class="name-text enabled" title="'+content.name+'">'+content.name+'</span>'
										+'</span>'
									+'</div>'
								+'</div>'
								+'<div class="fufHyA" style="width: 16%">'+content.fileSize+'</div>'
								+'<div class="fufHyA" style="width: 13%" title="'+content.updatedtime+'">'+content.updatedtime+'</div>'
								+'<div class="fufHyA" style="width: 10%">'
									+'<span class="search-feild" node-type="search-feild"'
											+'data-path="'+content.parentId+'" title="'+content.directory+'">'
											+content.directory+'</span>'
								+'</div>'
							+'</div>'
						}else{
							j += 1;
							html +=
							'<div class="item" id="'+content.id+'" style="height: 45px">'
								+'<div class="fufHyA c1" style="width: 60%">'
									+'<span class="MPbHyA">'
										+'<input class="mgc mgc-primary" type="checkbox" name="check-one" id="check-one" data-id="'+content.id+'">'
									+'</span>'
									+'<span class="ico global-icon-16" style="background: url(/nebula/'+content.icon+')"></span>'
									+'<div class="name">'
										+'<span class="name-text-wrapper">'
											+'<span class="name-text" style="cursor: default;" title="'+content.name+'">'+content.name+'</span>'
										+'</span>'
									+'</div>'
								+'</div>'
								+'<div class="fufHyA" style="width: 16%">'+content.fileSize+'</div>'
								+'<div class="fufHyA" style="width: 13%" title="'+content.updatedtime+'">'+content.updatedtime+'</div>'
								+'<div class="fufHyA" style="width: 10%">'
									+'<span class="search-feild" node-type="search-feild"'
											+'data-path="'+content.parentId+'" title="'+content.directory+'">'
											+content.directory+'</span>'
								+'</div>'
							+'</div>'
						}
					});
					if(i > 0 && j > 0){
						$(".CMxQsC").css("padding-right","17px");
					}else{
						$(".CMxQsC").css("padding-right","0px");
					}
					$(".CMxQsC ").html(
						'<div class="item">'
							+'<div class="fufHyA c1" style="width: 60%">'
								+'<span class="MPbHyA chk-all">'
									+'<input class="mgc mgc-primary" type="checkbox" name="check-all" id="check-all">'
								+'</span>'
								+'<div class="name">'
									+'<span>文件名</span>'
								+'</div>'
							+'</div>'
							+'<div class="fufHyA" style="width: 16%">大小</div>'
							+'<div class="fufHyA" style="width: 13%;">修改日期</div>'
							+'<div class="fufHyA" style="width: 10%">所在目录</div>'
						+'</div>'
					);
					if(html == ""){
						$(".list-view-home .list").html(
							'<div style="text-align: center;line-height: 40px;color: #333;">没有数据<div>'
						)
					}else{
						$(".list-view-home .list").html(html);
					}
				}
			});
		}
	});
	
	$(".search-clear").click(function(){
		$(".crumbs").html('<span class="item">全部文件</span>');
		$(this).hide();
		$(".search-key").val("");
		parentId = 0;
		info();
	});

	$(".CMxQsC").on("click","#check-all",function(){
		if($(this).is(":checked")){
			$("input[id=check-one]").each(function(){
				$(this).prop("checked",true);
				$(this).parents(".item").addClass("item-active");
			});
		}else{
			$("input[id=check-one]").each(function(){
				$(this).removeAttr("checked");
				$(this).parents(".item").removeClass("item-active");
			});
		}
	});
	
	$(".list").on("click","#check-one",function(){
		if($(this).is(":checked")){
			if($("input[id=check-one]").size() == $("input[id=check-one]:checked").size()){
				$("#check-all").prop("checked",true);
			}
			$(this).parents(".item").addClass("item-active");
		}else{
			$(this).parents(".item").removeClass("item-active");
			$("#check-all").removeAttr("checked");
		}
	});

	$(".list").on("click",".search-feild",function(){
		var id = $(this).parents(".item").attr("id");
		if(id.length <= 11){
			$(".crumbs").html(
				'<a node-type="crumbs-item" data-id="'+id+'" class="item" href="javascript:;">返回上一级</a>'
				+'<span class="crumbs-sep">|</span>'
				+'<a node-type="crumbs-item" data-id="0" class="item" href="javascript:;">全部文件</a>'
				+'<span class="crumbs-sep">&gt;</span>'
				+'<span class="item">'+$(this).html()+'</span>'
			);
		}else{
			$(".crumbs").html(
				'<a node-type="crumbs-item" data-id="'+$(this).attr("data-path").trim()+'" class="item" href="javascript:;">返回上一级</a>'
				+'<span class="crumbs-sep">|</span>'
				+'<a node-type="crumbs-item" data-id="0" class="item" href="javascript:;">全部文件</a>'
				+'<span class="crumbs-sep">&gt;</span>'
				+'<span class="item">'+$(this).html()+'</span>'
			);
		}
		parentId = $(this).attr("data-path").trim();
		info();
	});
	
	$(".view").click(function(){
		alert("该视图暂不可用");
	});
	
	$(".search-button").click(function(){
		$(this).hide();
		$(".search-key-wrapper").show();
	});
	
	$(".search-ico").click(function(){
		$(".search-key-wrapper").hide();
		$(".search-button").show();
	});
	
	$(".list").on("mouseenter",".item",function(){
		$(".list .item").removeClass("item-hover");
		$(this).addClass("item-hover");
	});
	
	$(".list").on("mouseleave",".item",function(){
		$(".list .item").removeClass("item-hover");
	});
	
	$(".list").on("click",".name-text",function(){
		if($(this).hasClass("enabled")){
			$(".crumbs").html(
				'<a node-type="crumbs-item" data-id="'+$(this).parents(".item").attr("id")+'" class="item" href="javascript:;">返回上一级</a>'
				+'<span class="crumbs-sep">|</span>'
				+'<a node-type="crumbs-item" data-id="0" class="item" href="javascript:;">全部文件</a>'
				+'<span class="crumbs-sep">&gt;</span>'
				+'<span class="item">'+$(this).html()+'</span>'
			);
			
			parentId = $(this).parents(".item").attr("id");
			info();
		}
	});
	
	$(".crumbs").on("click","a",function(){
		if($(this).attr("data-id") == 0){
			$(".crumbs").html('<span class="item">全部文件</span>');
			parentId = 0;
			info();
		}else{
			var dir;
			$.ajax({
				type: "post",
				url : "/nebula/folder/get-parentid.action",
				data: {
					folderId : $(this).attr("data-id"),
				},
				dataType: "json",
				async: false,
				success: function(_data){
					parentId = _data.data.folderid;
					dir = _data.data.folderName;
				}
			});
			info();
			if(parentId == 0){
				$(".crumbs").html('<span class="item">全部文件</span>');
			}else{
				$(".crumbs").html(
					'<a node-type="crumbs-item" data-id="'+parentId+'" class="item" href="javascript:;">返回上一级</a>'
					+'<span class="crumbs-sep">|</span>'
					+'<a node-type="crumbs-item" data-id="0" class="item" href="javascript:;">全部文件</a>'
					+'<span class="crumbs-sep">&gt;</span>'
					+'<span class="item">'+dir+'</span>'
				);
			}
		}
	});
	
	$(".sbtn").click(function(){
		var valArr = [];
		var friendname = "<%=request.getParameter("username")%>";
		var index = parent.layer.getFrameIndex(window.name);
		$("input[id=check-one]:checked").each(function(i){
			valArr[i] = $(this).attr("data-id");
		});
		if(valArr == ""){
			parent.layer.msg("请选择文件",{icon:2,time:2000,offset:"t"});
		}else if(valArr.toString().trim().length > 255){
			parent.layer.msg("选择分享的文件数量太多,请重新选择",{icon:2,time:2000,offset:"t"});
		}else{
			var title = $("input[id=check-one]:checked").parents(".item").find(".name-text").html();
			var size = $("input[id=check-one]:checked").size();
			if(size > 1){
				title += "等";
			}
			$.ajax({
				type: "post",
				url : "/nebula/friends/share-file.action",
				data: {
					title : title.trim(),
					valArr : valArr.toString().trim(),
					friendname : friendname.trim(),
				},
				dataType: "json",
				success: function(_data){
					parent.layer.msg(_data.msg,{icon:1,time:2000,offset:"t"});
					parent.layer.close(index);
				}
			});
		}
	});
})
</script>
</body>
</html>
